<template>
  <div id="cards">
    <div class="menu">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="色系名称" prop="colorSchemeName">
          <el-input
            v-model="queryParams.colorSchemeName"
            placeholder="请输入色系名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="温度℃" prop="temperature">
          <el-input
            v-model="queryParams.temperature"
            placeholder="请输入温度℃"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="压强Mpa" prop="pressure">
          <el-input
            v-model="queryParams.pressure"
            placeholder="请输入压强Mpa"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="时间" prop="timeConsuming">
          <el-input
            v-model="queryParams.timeConsuming"
            placeholder="请输入时间"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="合格" prop="acceptable">
          <el-select v-model="queryParams.acceptable" placeholder="请选择合格" clearable >
            <el-option
              v-for="dict in dict.type.test_result"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>

        </el-form-item>

      </el-form>
    </div>
    <div class="row-container">
      <div>符合条件实验数</div>
      <div class="card">{{ total}}</div>
    </div>
    <dv-scroll-board :config="config" />
  </div>
</template>

<script>
import {listExperimentDatasView} from "@/api/ruoyiyinzheng/experimentDatasView";

export default {
  name: 'Cards',
  dicts: ['test_result'],
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 全部实验数据表格数据
      experimentDatasViewList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        experimentNumber: undefined,
        clorlNumber: undefined,
        colorSchemeName: undefined,
        stRecieptName: undefined,
        co2: undefined,
        temperature: undefined,
        pressure: undefined,
        timeConsuming: undefined,
        wearproofColorFastnessDry: undefined,
        wearproofColorFastnessWet: undefined,
        washableColorFastnessStaining: undefined,
        washableColorFastnessDiscolor: undefined,
        shade: undefined,
        brilliance: undefined,
        whetherDyedEvenly: undefined,
        acceptable: undefined,
      },
      // 表单参数
      form: {},

      data: [],
      config: {
        header: ['实验编号', '色系', '色号', '配方','co2','温度','压强','时间','耐摩擦色牢度-干','耐摩擦色牢度-湿','耐水洗色牢度-沾色','耐水洗色牢度-变色','深浅度','鲜艳度','是否染匀','合格'],
        data: [],
        index: true,
        columnWidth: [50, 100, 100,50,150,50,50,50,50,150,150,150,150,100,100,100],
        align: ['center'],
        rowNum: 7,
        headerBGC: '#1981f6',
        headerHeight: 45,
        oddRowBGC: 'rgba(0, 44, 81, 0.8)',
        evenRowBGC: 'rgba(10, 29, 50, 0.8)'
      }
    }
  },
  methods: {
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleQuery() {
      listExperimentDatasView(this.queryParams).then(response => {
        this.experimentDatasViewList = response.rows;
        this.total = response.total;
        let temp = []
        console.log(this.experimentDatasViewList);
        for (let i = 0; i < this.experimentDatasViewList.length; i++) {
          let experimentNumber = this.experimentDatasViewList[i].experimentNumber;
          let colorSchemeName = this.experimentDatasViewList[i].colorSchemeName;
          let clorlNumber = this.experimentDatasViewList[i].clorlNumber;
          let stRecieptName = this.experimentDatasViewList[i].stRecieptName;
          let co2 = this.experimentDatasViewList[i].co2;
          let temperature = this.experimentDatasViewList[i].temperature;
          let pressure = this.experimentDatasViewList[i].pressure;
          let timeConsuming = this.experimentDatasViewList[i].timeConsuming;
          let wearproofColorFastnessDry = this.experimentDatasViewList[i].wearproofColorFastnessDry;
          let wearproofColorFastnessWet = this.experimentDatasViewList[i].wearproofColorFastnessWet;
          let washableColorFastnessStaining = this.experimentDatasViewList[i].washableColorFastnessStaining;
          let washableColorFastnessDiscolor = this.experimentDatasViewList[i].washableColorFastnessDiscolor;
          let shade = this.experimentDatasViewList[i].shade;
          let brilliance = this.experimentDatasViewList[i].brilliance;
          let whetherDyedEvenly = this.experimentDatasViewList[i].whetherDyedEvenly;
          let acceptable = '未检测';  // 初始化为 '未检测'
          if (this.experimentDatasViewList[i].acceptable === 'Y') {
            acceptable = '合格';
          } else if (this.experimentDatasViewList[i].acceptable === 'N') {
            acceptable = '不合格';
          }
          temp.push([experimentNumber, colorSchemeName, clorlNumber,
            stRecieptName,co2,temperature,pressure,timeConsuming,
            wearproofColorFastnessDry,wearproofColorFastnessWet,
            washableColorFastnessStaining,washableColorFastnessDiscolor,shade,brilliance,whetherDyedEvenly,acceptable]);
        }
        this.config.data = temp;
        this.config = {...this.config}
      });
    },


  },
  mounted () {
    this.handleQuery();
  }
}

</script>

<style lang="less">
#cards {
  display: flex;
  flex-wrap: wrap;
  background-color: rgba(6, 30, 93, 0.5);
  width: 100%;
  box-sizing: border-box;
  margin-left: 0px;
  height: 100%;
  overflow: hidden;

  .row-container{
    display: flex;
    flex-direction: row;
  }

  .card {

    background-color: rgba(4,49,128,.6);
    color: #08e5ff;
    height: 35px;
    width: 35px;
    font-size: 22px;
    font-weight: bold;
    line-height: 35px;
    text-align: center;
    margin: 10px;
  }

}



</style>
